﻿using System;
using Microsoft.VisualStudio.TestTools.LoadTesting;
using System.Threading;

namespace LoadTestingEmailRepoter.PulgIn
{
    /// <summary>
    /// VSTS Load Test Plug-in 
    /// By using Email Reporter: Load Test Plug-in, you will be able to send the load test reports to one or more pre-configured email addresses automatically, once a VSTS Load Test is completed. 
    /// This open-source load test plug-in also provides supports for customization by which you can customize the reported performance data.
    /// </summary>
    public class EmailReporterPlugin : ILoadTestPlugin
    {
        LoadTest reportingLoadTest;

        public void Initialize(LoadTest loadTest)
        {
            reportingLoadTest = loadTest;
            reportingLoadTest.LoadTestFinished += new EventHandler(myLoadTest_LoadTestFinished);
        }

        void myLoadTest_LoadTestFinished(object sender, EventArgs e)
        {
            new Thread(new ThreadStart(LoadTestReport.SendReport)).Start();
        }
    }
}
